home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 November / Chip Kasım 2000.iso / prog / share / 11 / setup.exe / %MAINDIR% / DEMOS / CIFTP / FTPEXP / exsppt.bas < prev    next >
Encoding:
BASIC Source File  |  2000-09-07  |  8.6 KB  |  233 lines

  1. Attribute VB_Name = "ExplorerSupport"
  2. Option Explicit
  3.  
  4. '<Constant>-----------------------------------------------------
  5. '---- misc
  6. Public Const nodPlaceHolder         As String = "..."
  7.  
  8. '---- Attachment constants
  9. '---- NodeTypes
  10. Public Const nodUndefined           As Integer = -1
  11. Public Const nodDesktop             As Integer = 1
  12. Public Const nodMyComputer          As Integer = 2
  13. Public Const nodFTPServers          As Integer = 3
  14. Public Const nodLocalDrive          As Integer = 4
  15. Public Const nodLocalFolder         As Integer = 5
  16. Public Const nodFTPServer           As Integer = 6
  17. Public Const nodFTPFolder           As Integer = 7
  18.  
  19. '---- Small and Large Icons
  20. Public Const imgDesktop             As Integer = 1
  21. Public Const imgPC                  As Integer = 2
  22. Public Const imgNetwork             As Integer = 3
  23. Public Const imgFolderClosed        As Integer = 4
  24. Public Const imgFolderOpen          As Integer = 5
  25. Public Const imgDriveNotShared      As Integer = 6
  26. Public Const imgDriveShared         As Integer = 7
  27. Public Const imgCDRom               As Integer = 8
  28. Public Const imgNetDrive            As Integer = 9
  29. Public Const imgFTPDrive            As Integer = 10
  30. Public Const imgLocalFile           As Integer = 11
  31. Public Const imgFTPFile             As Integer = 12
  32. Public Const imgFloppyDrive         As Integer = 13
  33. Public Const imgFTPServers          As Integer = 14
  34. Public Const imgPlaceHolder         As Integer = 15
  35.  
  36. '---- Toolbar
  37. Public Const imgUpOneLevel          As Integer = 1
  38. Public Const imgConNetDrive         As Integer = 2
  39. Public Const imgDisconNetDrive      As Integer = 3
  40. Public Const imgConFTPServer        As Integer = 4
  41. Public Const imgDisconFTPServer     As Integer = 5
  42. Public Const imgLargeIcons          As Integer = 6
  43. Public Const imgSmallIcons          As Integer = 7
  44. Public Const imgList                As Integer = 8
  45. Public Const imgDetails             As Integer = 9
  46. '</Constant>----------------------------------------------------
  47.  
  48. '---------------------------------------------------------------
  49. '<Purpose> checks to see is a key exists in a nodes collection
  50. '---------------------------------------------------------------
  51. Public Function IsKeyed(TheseNodes As Nodes, NodeKey As String) As Boolean
  52.     Dim InstanceNode As Node
  53.     
  54.     For Each InstanceNode In TheseNodes
  55.         If (InstanceNode.Key = NodeKey) Then
  56.             IsKeyed = True
  57.             GoTo Cleanup
  58.         End If
  59.     Next
  60.     
  61.     IsKeyed = False
  62.     
  63. Cleanup:
  64.     Set InstanceNode = Nothing
  65. End Function
  66.  
  67. '---------------------------------------------------------------
  68. '<Purpose> sets a ListViews ColumnHeader state for persistence
  69. '---------------------------------------------------------------
  70. Public Sub SetColumnHeaderState(ThisWindow As Form, ThisAppName As String)
  71.     Dim InstanceHeader  As ColumnHeader
  72.     Dim Header          As Integer
  73.     Dim Info            As String
  74.     Dim Section         As String
  75.     
  76.     Header = 1
  77.     For Each InstanceHeader In ThisWindow.List.ColumnHeaders
  78.         Section = "ListView Header " & Header
  79.         Info = CStr(InstanceHeader.Width)
  80.         Call SaveSetting(App.ProductName, ThisAppName, Section, Info)
  81.         Header = Header + 1
  82.     Next
  83.     
  84. End Sub
  85.  
  86. '---------------------------------------------------------------
  87. '<Purpose> sets the splitter bar position for persistence
  88. '---------------------------------------------------------------
  89. Public Sub SetSplitterBarState(ThisWindow As Form, ThisAppName As String)
  90.     Dim Info As String
  91.  
  92.     Info = CStr(ThisWindow.picSeparator.left)
  93.     Call SaveSetting(App.ProductName, ThisAppName, "SplitterBarState", Info)
  94.  
  95. End Sub
  96.  
  97. '---------------------------------------------------------------
  98. '<Purpose> gets the splitter bar position for persistence
  99. '---------------------------------------------------------------
  100. Public Sub GetSplitterBarState(ThisWindow As Form, ThisAppName As String)
  101.     Dim Info     As String
  102.  
  103.     If (App.ProductName = "") Then
  104.         MsgBox "You must enter a 'Product Name' using the EXE Options dialog box before you continue.", vbOKOnly + vbInformation
  105.         Exit Sub
  106.     End If
  107.     
  108.     'get the splitter info ------------------
  109.     Info = GetSetting(App.ProductName, ThisAppName, "SplitterBarState")
  110.     
  111.     'move the splitter to its new position ---------------
  112.     If (Info <> "") Then
  113.         Call ThisWindow.SplitMe(CInt(Info), ThisWindow.Tree)
  114.     End If
  115.     
  116. End Sub
  117.  
  118. '-----------------------------------------------------------------
  119. '<Purpose> puts all of the children of a node in the details list
  120. '-----------------------------------------------------------------
  121. Public Sub ListChildren(ThisExplorer As Form, ParentNode As Node)
  122.     Dim i               As Integer
  123.     Dim NumberChildren  As Integer
  124.     Dim WorkingItem     As ListItem
  125.     Dim TheseItems      As ListItems
  126.     Dim WorkingNode     As Node
  127.     
  128.     '---- cache ListItems collection
  129.     Set TheseItems = ThisExplorer.List.ListItems
  130.     
  131.     NumberChildren = ParentNode.Children
  132.     For i = 1 To NumberChildren
  133.         If (i = 1) Then
  134.             Set WorkingNode = ParentNode.Child
  135.         Else
  136.             Set WorkingNode = WorkingNode.Next
  137.         End If
  138.         
  139.         Set WorkingItem = TheseItems.Add(, WorkingNode.Key, WorkingNode.Text, WorkingNode.Image, WorkingNode.Image)
  140.     
  141.         '---  add type, size, and modified bits
  142.         'WorkingItem.SubItems(1) = not used
  143.         WorkingItem.SubItems(2) = Type2String(GetNodeType(ThisExplorer, WorkingNode))
  144.         'WorkingItem.SubItems(3) = not used
  145.     Next
  146.     
  147.     Set TheseItems = Nothing
  148.     Set WorkingItem = Nothing
  149.     Set WorkingNode = Nothing
  150. End Sub
  151.  
  152. '---------------------------------------------------------------
  153. '<Purpose> gets a ListViews ColumnHeader state for persistence
  154. '---------------------------------------------------------------
  155. Public Sub GetColumnHeaderState(ThisWindow As Form, ThisAppName As String)
  156.     Dim InstanceHeader  As ColumnHeader
  157.     Dim Header          As Integer
  158.     Dim Info            As String
  159.     Dim Section         As String
  160.     
  161.     If (App.ProductName = "") Then
  162.         MsgBox "You must enter a 'Product Name' using the EXE Options dialog box before you continue.", vbOKOnly + vbInformation
  163.         Exit Sub
  164.     End If
  165.     
  166.     Header = 1
  167.     For Each InstanceHeader In ThisWindow.List.ColumnHeaders
  168.         Section = "ListView Header " & Header
  169.         Info = GetSetting(App.ProductName, ThisAppName, Section)
  170.         If (Info <> "") Then
  171.             ThisWindow.List.ColumnHeaders(Header).Width = CInt(Info)
  172.         End If
  173.         Header = Header + 1
  174.     Next
  175. End Sub
  176.  
  177. '-------------------------------------------------------------------
  178. '<Purpose> gets the attachment for a given node
  179. '-------------------------------------------------------------------
  180. Public Function GetAttachment(ThisExplorer As Form, ThisNode As Node) As Attachment
  181.     
  182.     On Error GoTo NoAttachment
  183.     Set GetAttachment = ThisExplorer.Attachments.Item(ThisNode.Key)
  184.     On Error GoTo 0
  185.     Exit Function
  186.     
  187. NoAttachment:
  188.     Set GetAttachment = Nothing
  189.     On Error GoTo 0
  190.     
  191. End Function
  192.  
  193. '-------------------------------------------------------------------
  194. '<Purpose> gets the node type of a given node
  195. '-------------------------------------------------------------------
  196. Public Function GetNodeType(ThisExplorer As Form, ThisNode As Node) As Integer
  197.     Dim ThisAttachment  As Attachment
  198.     
  199.     On Error GoTo NoAttachment
  200.     Set ThisAttachment = ThisExplorer.Attachments.Item(ThisNode.Key)
  201.     GetNodeType = ThisAttachment.NodeType
  202.     
  203. Cleanup:
  204.     Set ThisAttachment = Nothing
  205.     On Error GoTo 0
  206.     Exit Function
  207.     
  208. NoAttachment:
  209.     GetNodeType = nodUndefined
  210.     GoTo Cleanup
  211.     
  212. End Function
  213.  
  214. '-------------------------------------------------------------------
  215. '<Purpose> converts a node type to a string
  216. '-------------------------------------------------------------------
  217. Public Function Type2String(NodeType As Integer) As String
  218.  
  219.     Select Case NodeType
  220.         Case nodUndefined:      Type2String = "Unidentified"
  221.         Case nodDesktop:        Type2String = "Desktop"
  222.         Case nodMyComputer:     Type2String = "My Computer"
  223.         Case nodFTPServers:     Type2String = "FTP Servers"
  224.         Case nodLocalDrive:     Type2String = "Local Drive"
  225.         Case nodLocalFolder:    Type2String = "Local Folder"
  226.         Case nodFTPServer:      Type2String = "FTP Server"
  227.         Case nodFTPFolder:      Type2String = "FTP Folder"
  228.         Case Else:              Type2String = "Unknown"
  229.     End Select
  230.  
  231. End Function
  232.  
  233.